From 19057e3760da6b3263c8512609b91044ed27eb17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Tue, 16 Sep 2025 18:27:56 +0200 Subject: [PATCH] luci-mod-network,-status: show DHCPv6 lease IAID MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The IAID is important information as it allows the user to know which interface on the client device a given DHCPv6 lease corresponds to. odhcpd already exposes this information (e.g. via "ubus call dhcp ipv6leases"), but it would be good to have access to the same information via the web interface, especially since odhcpd does take the IAID into account when allocating addresses. Signed-off-by: David Härdeman --- libs/rpcd-mod-luci/src/luci.c | 13 ++++++++----- .../luci-static/resources/view/network/dhcp.js | 2 ++ .../resources/view/status/include/40_dhcp.js | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/rpcd-mod-luci/src/luci.c b/libs/rpcd-mod-luci/src/luci.c index d9e2ab79ce..7cb56ae2af 100644 --- a/libs/rpcd-mod-luci/src/luci.c +++ b/libs/rpcd-mod-luci/src/luci.c @@ -355,6 +355,7 @@ struct lease_entry { struct ether_addr mac; char *hostname; char *duid; + char *iaid; union { struct in_addr in; struct in6_addr in6; @@ -487,16 +488,14 @@ lease_next(void) strtok(NULL, " \t\n"); /* iface */ e.duid = strtok(NULL, " \t\n"); /* duid */ - if (!e.duid) continue; - p = strtok(NULL, " \t\n"); /* iaid */ - - if (!p) + e.iaid = strtok(NULL, " \t\n"); /* iaid */ + if (!e.iaid) continue; - if (!strcmp(p, "ipv4")) { + if (!strcmp(e.iaid, "ipv4")) { e.af = AF_INET; e.mask = 32; } @@ -597,6 +596,7 @@ lease_next(void) e.hostname = strtok(NULL, " \t\n"); e.duid = strtok(NULL, " \t\n"); + e.iaid = NULL; if (!e.hostname || !e.duid) continue; @@ -1964,6 +1964,9 @@ rpc_luci_get_dhcp_leases(struct ubus_context *ctx, struct ubus_object *obj, if (lease->duid) blobmsg_add_string(&blob, "duid", lease->duid); + if (lease->iaid) + blobmsg_add_string(&blob, "iaid", lease->iaid); + inet_ntop(lease->af, &lease->addr[0].in6, s, sizeof(s)); blobmsg_add_string(&blob, (af == AF_INET) ? "ipaddr" : "ip6addr", s); diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 35c491da0a..d20c6c111f 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -58,6 +58,7 @@ CBILease6Status = form.DummyValue.extend({ E('th', { 'class': 'th' }, _('Hostname')), E('th', { 'class': 'th' }, _('IPv6 address')), E('th', { 'class': 'th' }, _('DUID')), + E('th', { 'class': 'th' }, _('IAID')), E('th', { 'class': 'th' }, _('Lease time remaining')) ]), E('tr', { 'class': 'tr placeholder' }, [ @@ -1417,6 +1418,7 @@ return view.extend({ host || '-', lease.ip6addrs ? lease.ip6addrs.join('
') : lease.ip6addr, lease.duid, + lease.iaid, exp ]; }), diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js index 61cfc62ac0..a98906f9fe 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/40_dhcp.js @@ -135,6 +135,7 @@ return baseclass.extend({ E('th', { 'class': 'th' }, _('Host')), E('th', { 'class': 'th' }, _('IPv6 address')), E('th', { 'class': 'th' }, _('DUID')), + E('th', { 'class': 'th' }, _('IAID')), E('th', { 'class': 'th' }, _('Lease time remaining')), isReadonlyView ? E([]) : E('th', { 'class': 'th cbi-section-actions' }, _('Static Lease')) ]) @@ -164,6 +165,7 @@ return baseclass.extend({ host || '-', lease.ip6addrs ? lease.ip6addrs.join('
') : lease.ip6addr, lease.duid, + lease.iaid, exp ]; -- 2.30.2